﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
<script>
    /* 用一个外部函数可以共享资源，但是容易造成命名冲突
	function myEat(parameters) {
        console.log("Eat beef!");
    }
	*/

    function Person(name, age) {
        this.name = name;
        this.age = age;
        //this.eat = myEat;
    }
	// 通过原型来添加方法
	Person.prototype.eat = function(){
		console.log("Eat Piza!");
	
	};
    var per1 = new Person("Carl", 34);
    var per2 = new Person("Daniel", 5);

    per1.eat();
    per2.eat();
	console.log("They are the same object?");
	console.log(per1 == per2);
	console.log("They are the same method?");
    console.log(per1.eat == per2.eat);


</script>

</body>
</html>